package org.sunsys.oozie.app.webui;

import java.util.Properties;

import org.apache.oozie.client.OozieClient;
import org.apache.oozie.client.OozieClientException;
import org.apache.oozie.client.WorkflowJob;
import org.sunsys.oozie.client.util.OozieClientUtil;
import org.sunsys.util.PropertiesFIleLoadingException;
import org.sunsys.util.PropertiesUtil;

public class WorkflowFacadeImpl implements WorkflowFacade {

	
	public WorkflowFacadeImpl() {
	}
	
	@Override
	public void startWorkflow(String workflowName) {
	}
	
	@Override
	public void killWorkflow(String workflowName) {
	}
	
	@Override
	public void updateJobStatus(String jobId) {
	}
	
	public static void main(String []args) {
		
		String oozieUrl = "http://192.168.120.129:11000/oozie";
		String jobPropertyFile = "/media/ravi/WorkEnvironment/Workspace/Software/oozie/oozie-4.0.1/examples/target/oozie-examples-4.0.1-examples/examples/apps/shell/job.properties";
		
		OozieClient oozieClient =  new OozieClient(oozieUrl);

		
		String workfloName = null;
		WorkflowJob workflowJob = null;
		try {
			Properties jobProperties = PropertiesUtil.getProperties(jobPropertyFile);
			System.out.println("job properties file is loaded");
			OozieClientUtil.addProperties(oozieClient, jobProperties);
			System.out.println("added the properties to the oozie client");
			workflowJob = oozieClient.getJobInfo(workfloName);
			System.out.println("Job info:");
		}catch(PropertiesFIleLoadingException e1){
			e1.printStackTrace();
		}catch(OozieClientException e1) {
			e1.printStackTrace();
		}
	}
}
